
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>投资记录</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0"/>
    <meta name="format-detection" content="telephone=no, email=no"/>
    <link rel="stylesheet" href="../css/common.css" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="../css/index.css"/>
    <link rel="stylesheet" href="../css/personalCenter.css" type="text/css">
    <!--插件样式表-->
    <link rel="stylesheet" href="../lib/css/dropload.css" type="text/css">
    <script src="../lib/js/jquery-2.1.4.js"></script>
    <script src="../lib/js/jquery.base64.js"></script>

    <!--插件-->
    <script src="../lib/js/dropload.js"></script>

    <script src="../js/wapframwork.js"></script>
</head>
<body>
<div class="wrap investmentRecord_page">
    <section class="container" style="background: #fff;">
        <header class="header investment_title" style="display: none;">
            <a href="personal.html">
                <i class="icon"></i>
            </a>
            <span>投资记录</span>
            <a href="personal.html">
                <i class="icon"></i>
            </a>
        </header>
        <section class="tabs">
            <ul class="tabs_nav clearFix" id="tabs_nav">
                <li class="list_item"><a href="investmentRecord.html">投标中<span></span></a></li>
                <li class=" list_item"><a href="investmentRecord2.html">回款中<span></span></a></li>
                <li class="active list_item"><a href="investmentRecord3.html">已还款<span id="count"></span></a></li>
            </ul>
            <ul class="tabs_sub_nav clearFix">
                <li class="list_item"><a href="javascript:;">标的信息</a></li>
                <li class="list_item"><a href="javascript:;">投资信息</a></li>
                <li class="list_item"><a href="javascript:;">更多操作</a></li>
            </ul>
            <div class="top_bar"></div>
        </section>
        <section class="tabs_wrap" id="tabs_wrap">
            <ul class="tabs_list"></ul>
            <!--回款中-->
            <!--<li>
                <a href="javascript:;">
                    <span>
                        <span class="title">投开薪DD16028期</span><span class="gray">12个月|12%</span>
                    </span>
                    <span>
                        <span class="gray">2017-01-05 12:00</span><span class="red">投资1000元</span>
                    </span>
                    <span><button class="downloadAgreement_btn">合同下载</button></span>
                </a>
            </li>-->
            <!--投标中-->
            <!-- <li>
                 <a href="javascript:;">
                     <span>
                         <span class="title">投开薪DD16028期</span><span class="gray">12个月|12%</span>
                     </span>
                     <span>
                         <span class="gray">2017-01-05 12:00</span><span class="red">投资1000元</span>
                     </span>
                     <span>
                         <span class="bar"><i></i><span class="percentNum">20%</span></span>
                         <span class="red">剩余10000元</span>
                     </span>
                 </a>
             </li>-->
            <!--已回款-->
            <!--<li>
                <a href="payment_details.html">
                    <span>
                        <span class="title">投开薪DD16028期</span><span class="gray">12个月|12%</span>
                    </span>
                    <span>
                        <span class="gray">2017-01-05 12:00</span><span class="red">投资1000元</span>
                    </span>
                    <span><button class="downloadAgreement_btn">查看明细</button></span>
                </a>
            </li>-->

        </section>
    </section>
</div>
</body>

<script>
    function RecordBid() {
        var self = this, _$type;

        /*副标题显示数量*/
        function total(num, ele) {
            var uid = getUIDByJWT().unique_name;
            $.ajax({
                type: "GET",
                url: getAPIURL() + "User/" + uid + "/investRecord?type=" + num + "&pageNumber=1&pageRows=11",
                dataType: "json",
                data: null,
                success: function (data) {
                    if (data.count) {
                        ele.html("(" + data.count + ")")
                    }


                },
                error: function () {
                },
                headers: {
                    "Authorization": "Bearer " + getTOKEN()
                }
            });
        }

        (function () {
            var _$pageno = 0;
            var _$tabs_nav, _$tab_wrap,_$tab_list;
            _$tabs_nav = $("#tabs_nav");
            _$tab_wrap = $("#tabs_wrap");
            _$tab_list=$(".tabs_list");

            /*标志变量 判断副标题是项目进度还是更多操作*/
            $(".top_bar").animate({left: _$tabs_nav.find("li.active").index() * _$tabs_nav.find("li").width() + _$tabs_nav.find("li").width() / 4});



            _$tabs_nav.find("li").each(function (index) {
                var oSpan = $(this).find("span");
                total(index + 1, oSpan);//显示当前标的的总数
            });

            var dropload = _$tab_wrap.dropload({
                domUp: {
                    domClass: 'dropload-up',
                    domRefresh: '<div class="dropload-refresh">↓下拉刷新</div>',
                    domUpdate: '<div class="dropload-update">↑释放更新</div>',
                    domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
                },
                domDown: {
                    domClass: 'dropload-down',
                    domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>',
                    domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                    domNoData: '<div class="dropload-noData">暂无数据</div>'
                },
                loadUpFn: function (me) {
                    /*重置页码数*/
                    var uid = getUIDByJWT().unique_name;
                    _$pageno=1;
                    $.ajax({
                        type: "GET",
                        url: getAPIURL() + "User/" + uid + "/investRecord?type=3&pageNumber=1&pageRows=20",
                        dataType: "json",
                        data: null,
                        success: function (data) {
                            var list = data.list;
                            var content = "";
                            if (list == undefined) {
                                $(".tabs_wrap").html("<ul><li class='nothing'><p>暂无记录</p><div class='noInvestment'><img src='../img/no_investment.png'></div></li></ul>");
                                // 即使加载出错，也得重置
                                dropload.resetload();
                            }
                            else {
                                for (var i = 0; i < list.length; i++) {
                                    content += '<li  class="list_item">' +
                                            '<a href="payment_details.html?type=3&invno=' + list[i].invno + '">' +
                                            '<span>' +
                                            '<span class="title">' + list[i].title + '</span><span class="gray">' + list[i].title_1 + '</span>' +
                                            '</span>' +
                                            '<span>' +
                                            '<span class="gray">' + list[i].invtime + '</span><span class="red">投资' + list[i].invamount + '元</span>' +
                                            '</span>' +
                                            '<span><button class="downloadAgreement_btn">查看明细</button></span>' +
                                            '</a>' +
                                            '</li>';
                                }
                                _$tab_list.html(content);
                                dropload.resetload();
                            }
                        },
                        error: function () {
                            $(".tabs_wrap").html("<ul><li class='nothing'><p>暂无记录</p><div class='noInvestment'><img src='../img/no_investment.png'></div></li></ul>");
                        },
                        headers: {
                            "Authorization": "Bearer " + getTOKEN()
                        }
                    });
                },
                loadDownFn: function (me) {
                    var uid = getUIDByJWT().unique_name;
                    _$pageno++;
                    $.ajax({
                        type: 'GET',
                        url: getAPIURL() + "User/" + uid + "/investRecord?type=3&pageNumber=" + _$pageno + "&pageRows=20",
                        dataType: 'json',
                        success: function (data) {
                            var list = data.list;
                            if (list == undefined) {
                                /*加载到最后没有数据*/
                                if(_$pageno==1){
                                    _$tab_wrap.html("<ul><li class='nothing'><p>暂无记录</p><div class='noInvestment'><img src='../img/no_investment.png'></div></li></ul>");
                                }
                                // 即使加载出错，也得重置
                                dropload.resetload();
                            }
                            else {
                                var content = "";
                                for (var i = 0; i < list.length; i++) {
                                    content += '<li class="list_item">' +
                                            '<a href="payment_details.html?type=3&invno=' + list[i].invno + '">' +
                                            '<span>' +
                                            '<span class="title">' + list[i].title + '</span><span class="gray">' + list[i].title_1 + '</span>' +
                                            '</span>' +
                                            '<span>' +
                                            '<span class="gray">' + list[i].invtime + '</span><span class="red">投资' + list[i].invamount + '元</span>' +
                                            '</span>' +
                                            '<span><button class="downloadAgreement_btn">查看明细</button></span>' +
                                            '</a>' +
                                            '</li>';
                                }
                                if(list.length<=$("#count").html().toString().slice(1,2)){
                                    dropload.noData(true);
                                }else {
                                    dropload.noData(false);
                                }
                                _$tab_list.append(content);
                                // 每次数据加载完，必须重置
                                me.resetload();
                            }
                        },
                        error: function (xhr, type) {
                            _$tab_wrap.html("<ul><li class='nothing'><p>哎呀，出错了！</p><div class='wrong'><img src='../img/no_reward.png'></div></li></ul>");
                            // 即使加载出错，也得重置
                            dropload.resetload();
                        },
                        headers: {
                            "Authorization": "Bearer " + getTOKEN()
                        }
                    });
                }
            });



        })();
    }
    var recordbid;
    $(function () {
        recordbid = new RecordBid();

    });
</script>

<script src="../lib/js/RainbowBridge.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    setTitle(".investment_title", {'title':'投资记录',"theme":"1"});
</script>
</html>
